feat(Segment Membership): Seed identities on Beta opt-in#7899
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Run seed tests against live ClickHouse with a mocked Dynamo source, inline the pending-task check, assert the whole skip event, use the ClickHouseIdentityRow type, and replace the management command with a Django admin re-seed action that clears the seed marker. beep boop Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB
for more information, see https://pre-commit.ci
khvn26
commented
Jun 27, 2026
khvn26
commented
Jun 27, 2026
khvn26
commented
Jun 27, 2026
…t-in Replace the daily all-org backfill with an on-demand seed_organisation_identities(organisation_id) task and a lightweight reconcile_segment_membership_seeds tick that fires it once per opted-in org, tracked by a SegmentMembershipSeed marker. Seeded rows are versioned at scan start so a CDC write landing mid-scan wins ReplacingMergeTree dedup. Keep a count-refresh safety-net as a separate recurring refresh_all_segment_counts task (cadence via SEGMENT_MEMBERSHIP_REFRESH_INTERVAL_HOURS, default 6) so cached counts track CDC identity churn between segment edits. All refresh enqueues - edit-triggered, seed fan-out, and the recurring sweep - route through enqueue_membership_refresh, the single flag and debounce gate, so a project never has duplicate refreshes queued. Add a Django admin action to force a re-seed by clearing the marker. beep boop Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB
…ith Exists Filter `organisation` directly on `Project` and test live-segment existence with a correlated `Exists`, instead of reaching the org through a segment join and feeding ids into `IN`. Drop the server-side cursor: scoped to one org this is a small set, and the heavy work is the per-project scan. beep boop Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB
… flag EOL beep boop Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB
Pulls the percentage-split row-translation fix so segments split by percentage report membership counts instead of showing empty. beep boop Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB
…ip-opt-in-seed # Conflicts: # api/uv.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #7471.
Closes #7911.
In this PR, we convert
backfill_identities_to_clickhouseto a seed backfill expected to run once per org.seed_organisation_identities(org_id)— on-demand one-shot seed for one org. Stampsinserted_atat scan start so a CDC write landing mid-scan wins ReplacingMergeTree dedup.reconcile_segment_membership_seeds(hourly) — fires the seed once per allowed org, tracked bySegmentMembershipSeedmodel.refresh_all_segment_countsevery 6 hours.SegmentMembershipSeedfor a given org).All tasks that run the expensive ClickHouse queries are debounced.
We also bump SQL engine dep to incorporate the % Split fix.
Review complexity: 2/5.
How did you test this code?
Added new tests and modified existing where needed; will test extensively in staging.